﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

namespace EntityMap
{
    public class DataUtility
    {
        public static object ConvertValue( string targetType, string value )
        {
            if( value == null )
            {
                return null;
            }

            switch( targetType )
            {
                case "string":
                    return value;
                case "int":
                    return Int32.Parse( value );
                case "datetime":
                    return DateTime.Parse( value );
                default:
                    return value;
            }
        }

        public static SqlDbType ConvertType( string targetType )
        {
            switch( targetType )
            {
                case "string":
                    return SqlDbType.VarChar;
                case "int":
                    return SqlDbType.Int;
                case "datetime":
                    return SqlDbType.DateTime;
                default:
                    return SqlDbType.VarChar;
            }
        }
    }
}
